package com.ruoyi.project.system.newfunction.service.impl;

import com.ruoyi.project.system.newfunction.domain.Depts;
import com.ruoyi.project.system.newfunction.mapper.DeptsMapper;
import com.ruoyi.project.system.newfunction.service.DeptsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
@Service
@Transactional
public class DeptsServiceImpl implements DeptsService {
    @Autowired
    private DeptsMapper deptsMapper;
    @Override
    public List<Depts> findAllByPage(Depts depts) {
        return deptsMapper.findAll(depts);
    }

    @Override
    public int saveDepts(Depts depts) {
        int lastDeptsId = deptsMapper.getLastDeptsId();
        depts.setDeptsId(lastDeptsId+1);
        depts.setCreateTime(new Date());
        return deptsMapper.addDepts(depts);
    }

    @Override
    public Depts findDpetsById(Integer deptsId) {
        return deptsMapper.getDeptsByDeptsId(deptsId);
    }

    @Override
    public int updateDepts(Depts depts) {
        depts.setUpdateTime(new Date());
        return deptsMapper.updateDepts(depts);
    }

    @Override
    public int removeDepts(Long[] deptsIds) {
        return deptsMapper.removeDepts(deptsIds);
    }
}
